﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace Ession.OCR
{
    /// <summary>
    ///     11平台的验证码
    /// </summary>

    public class ImageProcessor5211Game : ImageProcessor
    {

        public ImageProcessor5211Game(System.Drawing.Bitmap bmp)
        {
            MinRowIndex = -1;
            this.bmp = bmp;
            int minRow = int.MaxValue;

            for (int i = 0; i < bmp.Height; i++)
            {
                int color = 0;
                for (int j = 0; j < bmp.Width; j++)
                {
                    var c = bmp.GetPixel(j, i);
                    color += c.R + c.G + c.B;
                }
                if (color < minRow)
                {
                    minRow = color;
                    MinRowIndex = i;
                }
            }
        }

        public Bitmap bmp { get; set; }
        public int MinRowIndex { get; set; }
        public override void ProcessImage(Bitmap bmp)
        {

            for (int i = 0; i < bmp.Width; i++)
            {
                try
                {
                    if (EqualsCorlor(bmp.GetPixel(i, MinRowIndex - 1).R, bmp.GetPixel(i, MinRowIndex + 1).R))
                    {
                        bmp.SetPixel(i, 15, Color.White);
                    }
                }
                catch (Exception)
                { 

                } 
            } 
        }
    }
}
